ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
LIN_UART.c File Reference

Drivers for serial link (SCI/UART/LIN) More...

#include "derivative.h"
#include "Compile_Options.h"
#include "LIN_UART.h"

Functions

uint8_t u8fnUARTWrite (const uint8_t u8Instance, const uint8_t *pu8UARTTx, const uint8_t u8Size)
 This function will write n number of bytes to the UART. If this operation is not successful after some time, the routine will time-out. It will wait inside the function until all data has been transmitted.
uint8_t u8fnUARTRead (const uint8_t u8Instance, const uint8_t *pu8UARTRx, const uint8_t u8Size)
 This function will read n number of bytes from the UART and place them in an array before exiting. If the number is not achieved, the routine will time-out eventually.
uint8_t u8fnLINUARTSend (const uint8_t u8Instance, const uint8_t *pu8UARTTx, const uint8_t u8Size)
 This function will start writing data through the UART. The remaining data will be sent eventually through interrupts. It will NOT wait for all data to be sent before exiting.
uint8_t u8fnLINUARTReceive (const uint8_t u8Instance, const uint8_t *pu8UARTRx, const uint8_t u8IsrEn)
 This function will enable data to be received via a UART, and will allow data to keep flowing in indefinitely. This function will NOT wait for data to be ready before it exits.
uint8_t u8fnConfigLINUARTGeneral (const LINUARTConfig_t *tLINUARTConfig)
 This function will configure a particular instance of the LIN peripheral for use as a UART/SCI.
uint8_t u8fnLINUARTGetDataNoIsr (uint8_t u8Instance)
 Gathers data from the buffer without using Isrs.
uint8_t u8fnWaitForUARTTxBufferToEmpty (uint8_t u8Instance, uint32_t u32TimeOut)
 This function will wait for the Interrupts Enable bit to turn off or time-out while doing so. The purpose of such routine is to make sure not to start a new buffer transmission while there's one ongoing.
void vfnEnableLINTxISR (uint8_t u8Instance, uint8_t u8Switch)
 This internal function will enable or disable transmission interrupts.
void vfnEnableLINRxISR (uint8_t u8Instance, uint8_t u8Switch)
 This internal function will enable or disable Reception interrupts.
void vfnLIN0TxIsr (void)
 Interrupt Service routine for data transmission of Instance 0. This routine will call vfnGenericLINTxIsr.
void vfnLIN1TxIsr (void)
 Interrupt Service routine for data transmission of Instance 1. This routine will call vfnGenericLINTxIsr.
void vfnLIN2TxIsr (void)
 Interrupt Service routine for data transmission of Instance 2. This routine will call vfnGenericLINTxIsr.
void vfnLIN3TxIsr (void)
 Interrupt Service routine for data transmission of Instance 3. This routine will call vfnGenericLINTxIsr.
void vfnLIN0RxIsr (void)
 Interrupt Service routine for data reception of Instance 0. This routine will call vfnGenericLINTxIsr.
void vfnLIN1RxIsr (void)
 Interrupt Service routine for data reception of Instance 1. This routine will call vfnGenericLINTxIsr.
void vfnLIN2RxIsr (void)
 Interrupt Service routine for data reception of Instance 2. This routine will call vfnGenericLINTxIsr.
void vfnLIN3RxIsr (void)
 Interrupt Service routine for data reception of Instance 3. This routine will call vfnGenericLINTxIsr.

Variables

vuint8_t gau8LINUARTWordsTx [N_LIN_INSTANCES]
vuint8_t gau8LINUARTWordsRx [N_LIN_INSTANCES]
vuint8_t gau8LINUARTRxFlagHasBeenClearedByTx [N_LIN_INSTANCES]
vuint8_t * gpu8LINUARTTxBuffer [N_LIN_INSTANCES]
vuint8_t * gpu8LINUARTRxBuffer [N_LIN_INSTANCES]

Detailed Description

Drivers for serial link (SCI/UART/LIN)

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint8_t u8fnConfigLINUARTGeneral ( const LINUARTConfig_t tLINUARTConfig)

This function will configure a particular instance of the LIN peripheral for use as a UART/SCI.

Parameters:
LINUARTConfig_t,:pointer to a 32-bit word with relevant configuration. Refer to LINUARTConfig_t for more info.
Returns:
CLEAR if executed correctly; State-machine state in which the HW is stuck (as defined by LIN_STATE_MACHINE_STATES) otherwise.
uint8_t u8fnLINUARTGetDataNoIsr ( uint8_t  u8Instance)

Gathers data from the buffer without using Isrs.

Parameters:
u8Instance,:Value determining the LIN instance to read from.
Returns:
UART_NO_DATA_RX if no data is in the buffer; UART_INVALID_BUFFER_SIZE in case configuration for the buffer size is incorrect (should never happen); CLEAR if data has been gathered successfully.
uint8_t u8fnLINUARTReceive ( const uint8_t  u8Instance,
const uint8_t *  pu8UARTRx,
const uint8_t  u8IsrEn 
)

This function will enable data to be received via a UART, and will allow data to keep flowing in indefinitely. This function will NOT wait for data to be ready before it exits.

Parameters:
u8Instance,:Value determining the LIN instance from which data should be read.
pu8UARTRx,:Pointer to RAM location where incoming data should be placed.
u8IsrEn,:TRUE if Rx interrupts shall be used, CLEAR otherwise.
Returns:
UART_NOT_READY in case HW is in config mode and the operation couldn't thake place; CLEAR otherwise.
uint8_t u8fnLINUARTSend ( const uint8_t  u8Instance,
const uint8_t *  pu8UARTTx,
const uint8_t  u8Size 
)

This function will start writing data through the UART. The remaining data will be sent eventually through interrupts. It will NOT wait for all data to be sent before exiting.

Parameters:
u8Instance,:Value determining the LIN instance from which data should be read.
pu8UARTTx,:Pointer to data to transmit.
u8Size,:Amount of bytes to write.
Returns:
Clear if no problems find; UART_NOT_READY if HW or SW are not ready or busy with a previous Tx, or if HW state-machine does not change states as requested; UART_INVALID_BUFFER_SIZE if buffer size is not in agreement with HW settings;
uint8_t u8fnUARTRead ( const uint8_t  u8Instance,
const uint8_t *  pu8UARTRx,
const uint8_t  u8Size 
)

This function will read n number of bytes from the UART and place them in an array before exiting. If the number is not achieved, the routine will time-out eventually.

Parameters:
u8Instance,:Value determining the LIN instance from which data should be read.
pu8UARTRx,:Pointer to RAM location where incoming data should be placed.
u8Size,:Amount of bytes to be read.
Returns:
UART_NOT_READY in case HW is in config mode and the operation couldn't thake place; UART_TIMEOUT if we have timed-out without receiving all expected data; CLEAR otherwise.
uint8_t u8fnUARTWrite ( const uint8_t  u8Instance,
const uint8_t *  pu8UARTTx,
const uint8_t  u8Size 
)

This function will write n number of bytes to the UART. If this operation is not successful after some time, the routine will time-out. It will wait inside the function until all data has been transmitted.

Parameters:
u8Instance,:Value determining the LIN instance from which data should be read.
pu8UARTTx,:Pointer to data to transmit.
u8Size,:Amount of bytes to write.
Returns:
Clear if no problems find; UART_NOT_READY if HW or SW are not ready or busy with a previous Tx, or if HW state-machine does not change states as requested; UART_INVALID_BUFFER_SIZE if buffer size is not in agreement with HW settings; UART_TIMEOUT if we have timed-out without sending all data.
uint8_t u8fnWaitForUARTTxBufferToEmpty ( uint8_t  u8Instance,
uint32_t  u32TimeOut 
)

This function will wait for the Interrupts Enable bit to turn off or time-out while doing so. The purpose of such routine is to make sure not to start a new buffer transmission while there's one ongoing.

Parameters:
u8Instance,:Value determining the LIN instance to write to.
u32TimeOut,:Value to use as time-out. This value is decremented in a while loop. If it expires, an error flag UART_TIMEOUT is set.
Returns:
Clear if no problems find, UART_TIMEOUT if we have timed-out.
void vfnEnableLINRxISR ( uint8_t  u8Instance,
uint8_t  u8Switch 
)

This internal function will enable or disable Reception interrupts.

Parameters:
u8Instance,:Instance of the LIN module to operate on.
u8Switch,:Non-zero to enable, zero to disable.
Returns:
void.
Note:
This function should not be called by the user.
void vfnEnableLINTxISR ( uint8_t  u8Instance,
uint8_t  u8Switch 
)

This internal function will enable or disable transmission interrupts.

Parameters:
u8Instance,:Instance of the LIN module to operate on.
u8Switch,:Non-zero to enable, zero to disable.
Returns:
void.
void vfnLIN0RxIsr ( void  )

Interrupt Service routine for data reception of Instance 0. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN0TxIsr ( void  )

Interrupt Service routine for data transmission of Instance 0. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN1RxIsr ( void  )

Interrupt Service routine for data reception of Instance 1. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN1TxIsr ( void  )

Interrupt Service routine for data transmission of Instance 1. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN2RxIsr ( void  )

Interrupt Service routine for data reception of Instance 2. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN2TxIsr ( void  )

Interrupt Service routine for data transmission of Instance 2. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN3RxIsr ( void  )

Interrupt Service routine for data reception of Instance 3. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.
void vfnLIN3TxIsr ( void  )

Interrupt Service routine for data transmission of Instance 3. This routine will call vfnGenericLINTxIsr.

Parameters:
void.
Returns:
void.

Variable Documentation

vuint8_t gau8LINUARTRxFlagHasBeenClearedByTx[N_LIN_INSTANCES]

SW flag that is set when there is pending Rx data but the HW flag has been cleared by the Tx Done HW action.

vuint8_t gau8LINUARTWordsRx[N_LIN_INSTANCES]

Number of words that have been received per instance

vuint8_t gau8LINUARTWordsTx[N_LIN_INSTANCES]

Number of words to be transmitted per instance

vuint8_t* gpu8LINUARTRxBuffer[N_LIN_INSTANCES]

Rx Global for 8-bit transfers

vuint8_t* gpu8LINUARTTxBuffer[N_LIN_INSTANCES]

Tx Global for 8-bit transfers